/*
 *  CLRadeonExtender - Unofficial OpenCL Radeon Extensions Library
 *  Copyright (C) 2014-2018 Mateusz Szpakowski
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <CLRX/Config.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <climits>
#include <CLRX/utils/Utilities.h>

using namespace CLRX;

// type of float
enum FloatType
{
    FT_H, FT_F, FT_D
};

struct CStrtofXTestCase
{
    FloatType type;
    const char* string;
    uint64_t expected;
};

union FloatUnion
{
    float f;
    uint32_t u;
};

union DoubleUnion
{
    double d;
    uint64_t u;
};

static void testCStrtofX(cxuint testId, const CStrtofXTestCase& testCase)
{
    const char* end = nullptr;
    uint64_t result;
    cxuint width;
    const char* typeName;
    switch (testCase.type)
    {
        case FT_H:
        {
            // parse half float (FP16)
            uint16_t result16 = cstrtohCStyle(testCase.string,
                    testCase.string+::strlen(testCase.string), end);
            result = result16;
            width = 4;
            typeName = "half";
            break;
        }
        case FT_F:
        {
            // parse float (FP32)
            FloatUnion resultU;
            resultU.f = cstrtovCStyle<float>(testCase.string,
                    testCase.string+::strlen(testCase.string), end);
            result = resultU.u;
            width = 8;
            typeName = "float";
            break;
        }
        case FT_D:
        {
            // parse double (FP32)
            DoubleUnion resultU;
            resultU.d = cstrtovCStyle<double>(testCase.string,
                    testCase.string+::strlen(testCase.string), end);
            result = resultU.u;
            width = 16;
            typeName = "double";
            break;
        }
        default:
            throw Exception("Unknown type");
            break;
    }
    
    // if end is null or is not end of string
    if (end == nullptr || *end != 0)
    {
        std::ostringstream oss;
        oss << "Failed for #" << testId << " with string='" << testCase.string <<
                ". outend is null or doesn't points to zero" << std::endl;
        oss.flush();
        throw Exception(oss.str());
    }
    if (testCase.expected != result)
    {
        // result doesn't match
        std::ostringstream oss;
        oss << "Failed for #" << testId << " with string='" << testCase.string <<
               "' and type=" << typeName << ". Result: 0x";
        oss << std::hex << std::setw(width) << std::setfill('0') << testCase.expected <<
                "!=0x" << std::setw(width) << std::setfill('0') << result;
        oss.flush();
        throw Exception(oss.str());
    }
}

// testing floating point tripping between conversion from/to string
static void testTripping(cxuint testId, const CStrtofXTestCase& testCase)
{
    const char* end = nullptr;
    uint64_t result;
    uint64_t tripped1;
    uint64_t tripped2;
    cxuint width;
    const char* typeName;
    char buf1[64], buf2[32];
    switch (testCase.type)
    {
        case FT_H:
        {
            // for half float (FP16)
            uint16_t result16 = cstrtohCStyle(testCase.string,
                    testCase.string+::strlen(testCase.string), end);
            result = result16;
            width = 4;
            typeName = "half";
            htocstrCStyle(result16, buf1, 64, false);
            htocstrCStyle(result16, buf2, 64, true);
            result16 = cstrtohCStyle(buf1, buf1+::strlen(buf1), end);
            tripped1 = result16;
            result16 = cstrtohCStyle(buf2, buf2+::strlen(buf2), end);
            tripped2 = result16;
            break;
        }
        case FT_F:
        {
            // for float (FP32)
            FloatUnion resultU;
            resultU.f = cstrtovCStyle<float>(testCase.string,
                    testCase.string+::strlen(testCase.string), end);
            result = resultU.u;
            width = 8;
            typeName = "float";
            ftocstrCStyle(resultU.f, buf1, 64, false);
            ftocstrCStyle(resultU.f, buf2, 64, true);
            resultU.f = cstrtovCStyle<float>(buf1, buf1+::strlen(buf1), end);
            tripped1 = resultU.u;
            resultU.f = cstrtovCStyle<float>(buf2, buf2+::strlen(buf2), end);
            tripped2 = resultU.u;
            break;
        }
        case FT_D:
        {
            // for (FP64)
            DoubleUnion resultU;
            resultU.d = cstrtovCStyle<double>(testCase.string,
                    testCase.string+::strlen(testCase.string), end);
            result = resultU.u;
            width = 16;
            typeName = "double";
            dtocstrCStyle(resultU.d, buf1, 64, false);
            dtocstrCStyle(resultU.d, buf2, 64, true);
            resultU.d = cstrtovCStyle<double>(buf1, buf1+::strlen(buf1), end);
            tripped1 = resultU.u;
            resultU.d = cstrtovCStyle<double>(buf2, buf2+::strlen(buf2), end);
            tripped2 = resultU.u;
            break;
        }
        default:
            throw Exception("Unknown type");
            break;
    }
    if (result != tripped1 || result != tripped2)
    {
        // if result doesn't match (not this sample values)
        std::ostringstream oss;
        oss << "Failed tripping for #" << testId << " with string='" << testCase.string <<
               "' and type=" << typeName << ". Result: 0x";
        oss << std::hex << std::setw(width) << std::setfill('0') << result <<
                "!=0x" << std::setw(width) << std::setfill('0') << tripped1 <<
                "!=0x" << std::setw(width) << std::setfill('0') << tripped2;
        oss.flush();
        throw Exception(oss.str());
    }
}

static const CStrtofXTestCase cstrtofXTestCases[] =
{
    /* hex formatting */
    /***
     * half type
     ***/
    /* standard tests */
    { FT_H, "0x0", 0x0000 },
    { FT_H, "0x0.0", 0x0000 },
    { FT_H, "0x.00", 0x0000 },
    { FT_H, "0x0.00", 0x0000 },
    { FT_H, "0x1", 0x3c00 },
    { FT_H, "0x1p2", 0x4400 },
    { FT_H, "0xc4.d3p2", 0x6227 },
    { FT_H, "0x0.0c4d3p14", 0x6227 },
    { FT_H, "0x00c4d3.00p-6", 0x6227 },
    { FT_H, "0x189.a6p1", 0x6227 },
    { FT_H, "0x313.4cp0", 0x6227 },
    { FT_H, "0x626.98p-1", 0x6227 },
    { FT_H, "0x62.698p3", 0x6227 },
    { FT_H, "0x189a.6p-3", 0x6227 },
    { FT_H, "0x3134.cp-4", 0x6227 },
    { FT_H, "0x6269.8p-5", 0x6227 },
    /* half value rounding 0 */
    { FT_H, "0x7.b4p3", 0x53b4 },
    { FT_H, "0x7.b48p3", 0x53b4 },
    { FT_H, "0x7.b4800p3", 0x53b4 },
    { FT_H, "0x7.b47fp3", 0x53b4 },
    { FT_H, "0x7.b49p3", 0x53b5 },
    { FT_H, "0x7.b4801p3", 0x53b5 },
    { FT_H, "0x7.b58p3", 0x53b6 },
    { FT_H, "0x7.b5800p3", 0x53b6 },
    { FT_H, "0x7.b582p3", 0x53b6 },
    { FT_H, "0x7.b59p3", 0x53b6 },
    /* half value rounding 1 */
    { FT_H, "0x3.dap4", 0x53b4 },
    { FT_H, "0x3.da4p4", 0x53b4 },
    { FT_H, "0x3.da400p4", 0x53b4 },
    { FT_H, "0x3.da43p4", 0x53b5 },
    { FT_H, "0x3.da5p4", 0x53b5 },
    { FT_H, "0x3.dacp4", 0x53b6 },
    { FT_H, "0x3.dac00p4", 0x53b6 },
    { FT_H, "0x3.dadp4", 0x53b6 },
    { FT_H, "0x3.dac03p4", 0x53b6 },
    /* half value rounding 2 */
    { FT_H, "0x1.ed0p5", 0x53b4 },
    { FT_H, "0x1.ed2p5", 0x53b4 },
    { FT_H, "0x1.ed3p5", 0x53b5 },
    { FT_H, "0x1.ed21p5", 0x53b5 },
    { FT_H, "0x1.ed6p5", 0x53b6 },
    { FT_H, "0x1.ed7p5", 0x53b6 },
    { FT_H, "0x1.ed601p5", 0x53b6 },
    /* half value rounding 3 */
    { FT_H, "0x0.f68p6", 0x53b4 },
    { FT_H, "0x0.f69p6", 0x53b4 },
    { FT_H, "0x0.f6901p6", 0x53b5 },
    { FT_H, "0x0.f6bp6", 0x53b6 },
    { FT_H, "0x0.f6b03p6", 0x53b6 },
    /* half value rounding 4 */
    { FT_H, "0x7.b4p-5", 0x33b4 },
    { FT_H, "0x7.b48p-5", 0x33b4 },
    { FT_H, "0x7.b47fp-5", 0x33b4 },
    { FT_H, "0x7.b49p-5", 0x33b5 },
    { FT_H, "0x7.b4801p-5", 0x33b5 },
    { FT_H, "0x7.b58p-5", 0x33b6 },
    { FT_H, "0x7.b582p-5", 0x33b6 },
    { FT_H, "0x7.b59p-5", 0x33b6 },
    /* half value rounding 5 */
    { FT_H, "0x3.dap-4", 0x33b4 },
    { FT_H, "0x3.da4p-4", 0x33b4 },
    { FT_H, "0x3.da43p-4", 0x33b5 },
    { FT_H, "0x3.da5p-4", 0x33b5 },
    { FT_H, "0x3.dacp-4", 0x33b6 },
    { FT_H, "0x3.dadp-4", 0x33b6 },
    { FT_H, "0x3.dac03p-4", 0x33b6 },
    /* half value rounding 6 */
    { FT_H, "0x1.ed0p-3", 0x33b4 },
    { FT_H, "0x1.ed2p-3", 0x33b4 },
    { FT_H, "0x1.ed3p-3", 0x33b5 },
    { FT_H, "0x1.ed21p-3", 0x33b5 },
    { FT_H, "0x1.ed6p-3", 0x33b6 },
    { FT_H, "0x1.ed7p-3", 0x33b6 },
    { FT_H, "0x1.ed601p-3", 0x33b6 },
    /* half value rounding 7 */
    { FT_H, "0x0.f68p-2", 0x33b4 },
    { FT_H, "0x0.f69p-2", 0x33b4 },
    { FT_H, "0x0.f6901p-2", 0x33b5 },
    { FT_H, "0x0.f6bp-2", 0x33b6 },
    { FT_H, "0x0.f6b03p-2", 0x33b6 },
    /* half rounding on promotion */
    { FT_H, "0xf.fep5", 0x5fff },
    { FT_H, "0xf.ffp5", 0x6000 },
    { FT_H, "0xf.ff01p5", 0x6000 },
    { FT_H, "0x1f.fcp4", 0x5fff },
    { FT_H, "0x1f.fep4", 0x6000 },
    { FT_H, "0x1f.ffp4", 0x6000 },
    { FT_H, "0x1f.fe01p4", 0x6000 },
    { FT_H, "0x3f.f8p3", 0x5fff },
    { FT_H, "0x3f.fcp3", 0x6000 },
    { FT_H, "0x3f.fc01p3", 0x6000 },
    { FT_H, "0x7f.f0p2", 0x5fff },
    { FT_H, "0x7f.f8p2", 0x6000 },
    { FT_H, "0x7f.f9p2", 0x6000 },
    { FT_H, "0x7f.f801p2", 0x6000 },
    { FT_H, "0xf.fep-10", 0x23ff },
    { FT_H, "0xf.ffp-10", 0x2400 },
    { FT_H, "0xf.ff01p-10", 0x2400 },
    { FT_H, "0x1f.fcp-11", 0x23ff },
    { FT_H, "0x1f.fep-11", 0x2400 },
    { FT_H, "0x1f.fe01p-11", 0x2400 },
    { FT_H, "0x3f.f8p-12", 0x23ff },
    { FT_H, "0x3f.fcp-12", 0x2400 },
    { FT_H, "0x3f.fdp-12", 0x2400 },
    { FT_H, "0x3f.fc01p-12", 0x2400 },
    { FT_H, "0x7f.f0p-13", 0x23ff },
    { FT_H, "0x7f.f8p-13", 0x2400 },
    { FT_H, "0x7f.f9p-13", 0x2400 },
    { FT_H, "0x7f.f901p-13", 0x2400 },
    /* near infinity */
    { FT_H, "0x1.ffcp15", 0x7bff },
    { FT_H, "0x1.ffdffp15", 0x7bff },
    /* denormals */
    { FT_H, "0x1.dbp-15", 0x03b6 },
    { FT_H, "0x1.dbp-16", 0x01db },
    { FT_H, "0x1.dbp-17", 0x00ee },
    /* rounding denormals */
    { FT_H, "0x1.d3p-15", 0x03a6 },
    { FT_H, "0x1.d34p-15", 0x03a6 },
    { FT_H, "0x1.d3401p-15", 0x03a7 },
    { FT_H, "0x1.d35p-15", 0x03a7 },
    { FT_H, "0x1.d3cp-15", 0x03a8 },
    { FT_H, "0x1.d3dp-15", 0x03a8 },
    { FT_H, "0x1.d3c1p-15", 0x03a8 },
    /* rounding denormals promotion to normalized */
    { FT_H, "0x1.ffcp-15", 0x0400 },
    /* smallest denormal */
    { FT_H, "0x2.35p-25", 0x0001 },
    { FT_H, "0x2.0000p-26", 0x0000 },
    { FT_H, "0x1.fff0p-26", 0x0000 },
    { FT_H, "0x2.0000p-27", 0x0000 },
    { FT_H, "0x3.35p-25", 0x0002 },
    /***
     * float type
     ***/
    /* standard tests */
    { FT_F, "0x0", 0x00000000 },
    { FT_F, "0x0.0", 0x00000000 },
    { FT_F, "0x.00", 0x00000000 },
    { FT_F, "0x0.00", 0x00000000 },
    { FT_F, "0x1", 0x3f800000 },
    { FT_F, "0x1p2", 0x40800000 },
    { FT_F, "0x6a8.dc843p-4", 0x42d51b91 },
    { FT_F, "0x.6a8dc843p8", 0x42d51b91 },
    { FT_F, "0x3546.e4218p-7", 0x42d51b91 },
    { FT_F, "0x1aa3.7210cp-6",  0x42d51b91 },
    { FT_F, "0xd51.b9086p-5", 0x42d51b91 },
    { FT_F, "0x35.46e4218p1", 0x42d51b91 },
    { FT_F, "0x1a.a37210cp2",  0x42d51b91 },
    { FT_F, "0xd.51b9086p3", 0x42d51b91 },
    { FT_F, "0x.3546e4218p9", 0x42d51b91 },
    { FT_F, "0x.1aa37210cp10",  0x42d51b91 },
    { FT_F, "0x.0d51b9086p11", 0x42d51b91 },
    /* float value rounding 0 */
    { FT_F, "0x5.d98ca8p12", 0x46bb3195 },
    { FT_F, "0x5.d98cacp12", 0x46bb3196 },
    { FT_F, "0x5.d98cac00p12", 0x46bb3196 },
    { FT_F, "0x5.d98cac01p12", 0x46bb3196 },
    { FT_F, "0x5.d98cadp12", 0x46bb3196 },
    { FT_F, "0x5.d98ca0p12", 0x46bb3194 },
    { FT_F, "0x5.d98ca4p12", 0x46bb3194 },
    { FT_F, "0x5.d98ca400p12", 0x46bb3194 },
    { FT_F, "0x5.d98ca5p12", 0x46bb3195 },
    { FT_F, "0x5.d98ca4003p12", 0x46bb3195 },
    /* float value rounding 1 */
    { FT_F, "0xb.b3194p11", 0x46bb3194 },
    { FT_F, "0xb.b31948p11", 0x46bb3194 },
    { FT_F, "0xb.b3194800p11", 0x46bb3194 },
    { FT_F, "0xb.b31949p11", 0x46bb3195 },
    { FT_F, "0xb.b3194801p11", 0x46bb3195 },
    { FT_F, "0xb.b3195p11", 0x46bb3195 },
    { FT_F, "0xb.b31958p11", 0x46bb3196 },
    { FT_F, "0xb.b31958000p11", 0x46bb3196 },
    { FT_F, "0xb.b31959p11", 0x46bb3196 },
    { FT_F, "0xb.b3195802p11", 0x46bb3196 },
    /* float value rounding 2 */
    { FT_F, "0x17.66328p10", 0x46bb3194 },
    { FT_F, "0x17.66329p10", 0x46bb3194 },
    { FT_F, "0x17.6632901p10", 0x46bb3195 },
    { FT_F, "0x17.6632ap10", 0x46bb3195 },
    { FT_F, "0x17.6632bp10", 0x46bb3196 },
    { FT_F, "0x17.6632b01p10", 0x46bb3196 },
    { FT_F, "0x17.6632b2p10", 0x46bb3196 },
    /* float value rounding 3 */
    { FT_F, "0x2e.cc650p9", 0x46bb3194 },
    { FT_F, "0x2e.cc652p9", 0x46bb3194 },
    { FT_F, "0x2e.cc653p9", 0x46bb3195 },
    { FT_F, "0x2e.cc65202p9", 0x46bb3195 },
    { FT_F, "0x2e.cc654p9", 0x46bb3195 },
    { FT_F, "0x2e.cc656p9", 0x46bb3196 },
    { FT_F, "0x2e.cc6561p9", 0x46bb3196 },
    /* float rounding on promotion */
    { FT_F, "0x1.ffffffp-5", 0x3d800000 },
    { FT_F, "0x1.ffffff1p-5", 0x3d800000 },
    { FT_F, "0x1.ffffff01p-5", 0x3d800000 },
    { FT_F, "0x3.fffffep-6", 0x3d800000 },
    { FT_F, "0x3.fffffe1p-6", 0x3d800000 },
    { FT_F, "0x3.ffffffp-6", 0x3d800000 },
    { FT_F, "0x3.fffffe01p-6", 0x3d800000 },
    { FT_F, "0x7.fffffcp-7", 0x3d800000 },
    { FT_F, "0x7.fffffdp-7", 0x3d800000 },
    { FT_F, "0x7.fffffc1p-7", 0x3d800000 },
    { FT_F, "0x7.fffffc01p-7", 0x3d800000 },
    { FT_F, "0xf.fffff8p-8", 0x3d800000 },
    { FT_F, "0xf.fffff9p-8", 0x3d800000 },
    { FT_F, "0xf.fffff81p-8", 0x3d800000 },
    { FT_F, "0xf.fffff801p-8", 0x3d800000 },
    /* near infinity */
    { FT_F, "0x1.fffffep127", 0x7f7fffff },
    { FT_F, "0x3.fffffcp126", 0x7f7fffff },
    /* denormals */
    { FT_F, "0x1.cdfd9cep-129", 0x001cdfda },
    { FT_F, "0x6.c85bfp-132", 0x000d90b8 },
    /* rounding denormals */
    { FT_F, "0x4.c9d48p-129", 0x004c9d48 },
    { FT_F, "0x4.c9d488p-129", 0x004c9d48 },
    { FT_F, "0x4.c9d48800p-129", 0x004c9d48 },
    { FT_F, "0x4.c9d48801p-129", 0x004c9d49 },
    { FT_F, "0x4.c9d498p-129", 0x004c9d4a },
    { FT_F, "0x4.c9d49800p-129", 0x004c9d4a },
    { FT_F, "0x4.c9d49801p-129", 0x004c9d4a },
    { FT_F, "0x9.93a910p-130", 0x004c9d48 },
    { FT_F, "0x9.93a911p-130", 0x004c9d49 },
    { FT_F, "0x9.93a912p-130", 0x004c9d49 },
    { FT_F, "0x9.93a911p-130", 0x004c9d49 },
    { FT_F, "0x9.93a93p-130", 0x004c9d4a },
    { FT_F, "0x9.93a93001p-130", 0x004c9d4a },
    /* rounding denormals promotion to normalized */
    { FT_F, "0x3.fffffcp-128", 0x00800000 },
    { FT_F, "0x3.fffffc001p-128", 0x00800000 },
    { FT_F, "0x3.fffffc00p-128", 0x00800000 },
    { FT_F, "0x3.fffffdp-128", 0x00800000 },
    /* smallest denormal */
    { FT_F, "0x2.0334p-150", 0x00000001 },
    { FT_F, "0x2.000p-150", 0x00000001 },
    { FT_F, "0x2p-150", 0x00000001 },
    { FT_F, "0x2p-151", 0x00000000 },
    { FT_F, "0x1.fffffp-151", 0x00000000 },
    { FT_F, "0x2p-152", 0x00000000 },
    { FT_F, "0x2p-157", 0x00000000 },
    /***
     * double type
     ***/
    /* standard tests */
    { FT_D, "0x0", 0x0000000000000000ULL },
    { FT_D, "0x0.0", 0x0000000000000000ULL },
    { FT_D, "0x.00", 0x0000000000000000ULL },
    { FT_D, "0x0.00", 0x0000000000000000ULL },
    { FT_D, "0x1", 0x3ff0000000000000ULL },
    { FT_D, "0x1p2", 0x4010000000000000ULL },
    { FT_D, "0x5.3848c9d8a984bp17", 0x4124e1232762a613ULL },
    { FT_D, "0xa.709193b153096p16", 0x4124e1232762a613ULL },
    { FT_D, "0x14.e1232762a612cp15", 0x4124e1232762a613ULL },
    { FT_D, "0x29.c2464ec54c258p14", 0x4124e1232762a613ULL },
    { FT_D, "0x5.3848c9d8a984bp-22", 0x3eb4e1232762a613ULL },
    { FT_D, "0xa.709193b153096p-23", 0x3eb4e1232762a613ULL },
    { FT_D, "0x14.e1232762a612cp-24", 0x3eb4e1232762a613ULL },
    { FT_D, "0x29.c2464ec54c258p-25", 0x3eb4e1232762a613ULL },
    /* float value rounding 0 */
    { FT_D, "0x4.59cd9a48b93fcp14", 0x40f167366922e4ffULL },
    { FT_D, "0x4.59cd9a48b93fep14", 0x40f167366922e500ULL },
    { FT_D, "0x4.59cd9a48b93fe00p14", 0x40f167366922e500ULL },
    { FT_D, "0x4.59cd9a48b93fe01p14", 0x40f167366922e500ULL },
    { FT_D, "0x4.59cd9a48b93f8p14", 0x40f167366922e4feULL },
    { FT_D, "0x4.59cd9a48b93fap14", 0x40f167366922e4feULL },
    { FT_D, "0x4.59cd9a48b93fbp14", 0x40f167366922e4ffULL },
    { FT_D, "0x4.59cd9a48b93fa01p14", 0x40f167366922e4ffULL },
    { FT_D, "0x4.59cd9a48b93fa00p14", 0x40f167366922e4feULL },
    /* float rounding on promotion */
    { FT_D, "0x7.ffffffffffffep-5", 0x3fd0000000000000ULL },
    { FT_D, "0x7.ffffffffffffe01p-5", 0x3fd0000000000000ULL },
    { FT_D, "0x7.ffffffffffffe00p-5", 0x3fd0000000000000ULL },
    /* near infinity */
    { FT_D, "0x7.ffffffffffffcp1021", 0x7fefffffffffffffULL },
    { FT_D, "0x7ff.ffffffffffcp1013", 0x7fefffffffffffffULL },
    /* denormals */
    { FT_D, "0xd.5cdb9d9ap-1031", 0x00006ae6dcecd000ULL },
    { FT_D, "0xd.5cdb9d3f9bap-1031", 0x00006ae6dce9fcddULL },
    { FT_D, "0xd.5cdb9d3f9bbp-1031", 0x00006ae6dce9fcdeULL },
    /* rounding denormals */
    { FT_D, "0x3.cd9b9548a7cp-1032", 0x00000f366e55229fULL },
    { FT_D, "0x3.cd9b9548a7ep-1032", 0x00000f366e5522a0ULL },
    { FT_D, "0x3.cd9b9548a7e01p-1032", 0x00000f366e5522a0ULL },
    { FT_D, "0x3.cd9b9548a7e00p-1032", 0x00000f366e5522a0ULL },
    { FT_D, "0x3.cd9b9548a7ap-1032", 0x00000f366e55229eULL },
    { FT_D, "0x3.cd9b9548a7a01p-1032", 0x00000f366e55229fULL },
    { FT_D, "0x3.cd9b9548a7a00p-1032", 0x00000f366e55229eULL },
    /* rounding denormals promotion to normalized */
    { FT_D, "0x3.ffffffffffffep-1024", 0x0010000000000000ULL },
    { FT_D, "0x3.fffffffffffffp-1024", 0x0010000000000000ULL },
    { FT_D, "0x3.ffffffffffffe00p-1024", 0x0010000000000000ULL },
    { FT_D, "0x3.ffffffffffffe01p-1024", 0x0010000000000000ULL },
    /* smallest denormal */
    { FT_D, "0x4.0cdcap-1076", 0x0000000000000001ULL },
    { FT_D, "0x4.0cdcap-1077", 0x0000000000000001ULL },
    { FT_D, "0x2.0cdcap-1077", 0x0000000000000000ULL },
    /*
     * dec formatting
     */
    /*
     * simple examples (half)
     */
    { FT_H, "0", 0x0000 },
    { FT_H, "0000", 0x0000 },
    { FT_H, "00.00", 0x0000 },
    { FT_H, ".0", 0x0000 },
    { FT_H, "0.", 0x0000 },
    { FT_H, "0.0", 0x0000 },
    { FT_H, ".000000", 0x0000 },
    { FT_H, "0.0e-865776", 0x0000 },
    { FT_H, "0.0e+3898289", 0x0000 },
    { FT_H, "-0", 0x8000 },
    { FT_H, "-0000", 0x8000 },
    { FT_H, "-00.00", 0x8000 },
    { FT_H, "-.0", 0x8000 },
    { FT_H, "-0.", 0x8000 },
    { FT_H, "-0.0", 0x8000 },
    { FT_H, "-.000000", 0x8000 },
    { FT_H, "-0.0e-865776", 0x8000 },
    { FT_H, "-0.0e+3898289", 0x8000 },
    { FT_H, "1", 0x3c00 },
    { FT_H, "-1", 0xbc00 },
    { FT_H, "1.", 0x3c00 },
    { FT_H, "001", 0x3c00 },
    { FT_H, "001.000", 0x3c00 },
    { FT_H, "10000e-4", 0x3c00 },
    { FT_H, "0.0001e4", 0x3c00 },
    { FT_H, ".00010e4", 0x3c00 },
    { FT_H, "0.000000000000001e15", 0x3c00 },
    { FT_H, "0.0000000000000010000e15", 0x3c00 },
    { FT_H, "1.5", 0x3e00 },
    { FT_H, "1.25", 0x3d00 },
    { FT_H, "1.75", 0x3f00 },
    { FT_H, "3", 0x4200 },
    { FT_H, "12", 0x4a00 },
    { FT_H, "176", 0x5980 },
    { FT_H, "2000", 0x67d0 },
    { FT_H, "0.3333333333", 0x3555 },
    { FT_H, "0.1", 0x2e66 },
    { FT_H, "0.2", 0x3266 },
    { FT_H, "0.07541", 0x2cd4 },
    { FT_H, "4.871e-5", 0x0331 },
    /*
     * simple examples (float)
     */
    { FT_F, "0", 0x00000000 },
    { FT_F, "0000", 0x00000000 },
    { FT_F, "00.00", 0x00000000 },
    { FT_F, ".0", 0x00000000 },
    { FT_F, "0.", 0x00000000 },
    { FT_F, "0.0", 0x00000000 },
    { FT_F, ".000000", 0x00000000 },
    { FT_F, "0.0e-865776", 0x00000000 },
    { FT_F, "0.0e+3898289", 0x00000000 },
    { FT_F, "-0", 0x80000000 },
    { FT_F, "-0000", 0x80000000 },
    { FT_F, "-00.00", 0x80000000 },
    { FT_F, "-.0", 0x80000000 },
    { FT_F, "-0.", 0x80000000 },
    { FT_F, "-0.0", 0x80000000 },
    { FT_F, "-.000000", 0x80000000 },
    { FT_F, "-0.0e-865776", 0x80000000 },
    { FT_F, "-0.0e+3898289", 0x80000000 },
    { FT_F, "1", 0x3f800000 },
    { FT_F, "-1", 0xbf800000 },
    { FT_F, "1.", 0x3f800000 },
    { FT_F, "001", 0x3f800000 },
    { FT_F, "001.000", 0x3f800000 },
    { FT_F, "10000e-4", 0x3f800000 },
    { FT_F, "0.0001e4", 0x3f800000 },
    { FT_F, ".00010e4", 0x3f800000 },
    { FT_F, "0.000000000000001e15", 0x3f800000 },
    { FT_F, "0.0000000000000010000e15", 0x3f800000 },
    { FT_F, "1.5", 0x3fc00000 },
    { FT_F, "1.25", 0x3fa00000 },
    { FT_F, "1.75", 0x3fe00000 },
    { FT_F, "3", 0x40400000 },
    { FT_F, "12", 0x41400000 },
    { FT_F, "176", 0x43300000 },
    { FT_F, "2000", 0x44fa0000 },
    { FT_F, "0.3333333333", 0x3eaaaaab },
    { FT_F, "0.1", 0x3dcccccd },
    { FT_F, "0.2", 0x3e4ccccd },
    { FT_F, "0.07541", 0x3d9a708f },
    { FT_F, "4.871e-5", 0x384c4df7 },
    /*
     * simple examples (double)
     */
    { FT_D, "0", 0x0000000000000000ULL },
    { FT_D, "0000", 0x0000000000000000ULL },
    { FT_D, "00.00", 0x0000000000000000ULL },
    { FT_D, ".0", 0x0000000000000000ULL },
    { FT_D, "0.", 0x0000000000000000ULL },
    { FT_D, "0.0", 0x0000000000000000ULL },
    { FT_D, ".000000", 0x0000000000000000ULL },
    { FT_D, "0.0e-865776", 0x0000000000000000ULL },
    { FT_D, "0.0e+3898289", 0x0000000000000000ULL },
    { FT_D, "-0", 0x8000000000000000ULL },
    { FT_D, "-0000", 0x8000000000000000ULL },
    { FT_D, "-00.00", 0x8000000000000000ULL },
    { FT_D, "-.0", 0x8000000000000000ULL },
    { FT_D, "-0.", 0x8000000000000000ULL },
    { FT_D, "-0.0", 0x8000000000000000ULL },
    { FT_D, "-.000000", 0x8000000000000000ULL },
    { FT_D, "-0.0e-865776", 0x8000000000000000ULL },
    { FT_D, "-0.0e+3898289", 0x8000000000000000ULL },
    { FT_D, "1", 0x3ff0000000000000ULL },
    { FT_D, "-1", 0xbff0000000000000ULL },
    { FT_D, "1.", 0x3ff0000000000000ULL },
    { FT_D, "001", 0x3ff0000000000000ULL },
    { FT_D, "001.000", 0x3ff0000000000000ULL },
    { FT_D, "10000e-4", 0x3ff0000000000000ULL },
    { FT_D, "0.0001e4", 0x3ff0000000000000ULL },
    { FT_D, ".00010e4", 0x3ff0000000000000ULL },
    { FT_D, "0.000000000000001e15", 0x3ff0000000000000ULL },
    { FT_D, "0.0000000000000010000e15", 0x3ff0000000000000ULL },
    { FT_D, "1.5", 0x3ff8000000000000ULL },
    { FT_D, "1.25", 0x3ff4000000000000ULL },
    { FT_D, "1.75", 0x3ffc000000000000ULL },
    { FT_D, "3", 0x4008000000000000ULL },
    { FT_D, "12", 0x4028000000000000ULL },
    { FT_D, "176", 0x4066000000000000ULL },
    { FT_D, "2000", 0x409f400000000000ULL },
    { FT_D, "0.3333333333", 0x3fd55555554c2bb5ULL },
    { FT_D, "0.1", 0x3fb999999999999aULL },
    { FT_D, "0.2", 0x3fc999999999999aULL },
    { FT_D, "0.07541", 0x3fb34e11dbca9692ULL },
    { FT_D, "4.871e-5", 0x3f0989bedb1c9bc2ULL },
    /***
     * double type
     ***/
    { FT_D, "95367431640625e-20", 0x3eb0000000000000ULL },
    { FT_D, "9536743164062500000e-25", 0x3eb0000000000000ULL },
    { FT_D, "9945777114545532437e-22", 0x3f504b8faf9e26e8ULL },
    { FT_D, "124.349554000000007969706281937785303667133e-3", 0x3fbfd55f53b3c277ULL },
    { FT_D, "0.0003977388122115383067931709826225983306358102709054946899414062500000010000",
        0x3f3a10f330d82aafULL },
    { FT_D, "0.0003977388122115383067931709826225983306358102709054946899414062500000000000",
        0x3f3a10f330d82aaeULL },
    { FT_D, "0.000397738812211538361003279606897820031008450314402580261230468750001",
        0x3f3a10f330d82ab0ULL },
    { FT_D, "113459617318868155891712.0000000", 0x44b806a87e70b1ceULL },
    { FT_D, "113459617318868155891712.0000001", 0x44b806a87e70b1cfULL },
    { FT_D, "260798.51045265670109074562788009643554687499999999999999999999999999999999999",
        0x410fd5f4156833d5ULL },
    { FT_D, "9.3382310117836310024024833389745051853737339389705490689363285444"
        "2977335114755213659953273100713218573168562007456485035103951033074982"
        "6984870333105555294156097457575072418124470158069656870604595909636048"
        "1483563284807882501667773499272457796347955474030068409731592371841989"
        "5653178653199408426549140896028373810709881106128799002407093653135857"
        "8744945742284838808913104437938306426616512244244475008136781237107204"
        "5785069803969236090779304504394531250001E-172", 0x1c6cdecf9b1d737fULL },
    { FT_D, "179769313486231580793728971405303415079934132710037826936173778980"
        "4449682927647509466490179775872070963302864166928879109465555478519404"
        "0263065748867150582068190890200070838367627385484581771153176447573027"
        "0069855571366959622842914819860834936475292719074168444365510704342711"
        "559699508093042880177904174497791", 0x7fefffffffffffffULL },
    { FT_D, "2.3842382414947637549596743920787455590168291452061977645019416265"
        "8007364300956137946581802602434988637608860318743421107302594565381434"
        "3907655495539490512969123111059807018151749705668300945273496166383558"
        "7354360345093152101953020185788440196681140734022880211135171950821368"
        "7310598845091083234490175624889320063491822015186328788837729252992837"
        "2315832147588909406347279981227416109949432710265209746516486407465612"
        "7030603494885223902621274726610974519759364140084269277022610605086004"
        "9783710180292937259437895734151007299711087928015849205778112058612716"
        "3581090420287544009107375983137986965934137866869925215909304102650777"
        "1845769918056379742716259356596382272090373493890580856019378332302410"
        "596915991454573020513177557255790617318780277855694293975830078125E-315",
        0x000000001cc38358ULL },
    { FT_D, "2.3842382414947637549596743920787455590168291452061977645019416265"
        "8007364300956137946581802602434988637608860318743421107302594565381434"
        "3907655495539490512969123111059807018151749705668300945273496166383558"
        "7354360345093152101953020185788440196681140734022880211135171950821368"
        "7310598845091083234490175624889320063491822015186328788837729252992837"
        "2315832147588909406347279981227416109949432710265209746516486407465612"
        "7030603494885223902621274726610974519759364140084269277022610605086004"
        "9783710180292937259437895734151007299711087928015849205778112058612716"
        "3581090420287544009107375983137986965934137866869925215909304102650777"
        "1845769918056379742716259356596382272090373493890580856019378332302410"
        "59691599145457302051317755725579061731878027785569429397583007812501E-315",
        0x000000001cc38359ULL },
    { FT_D, "6829714151864270.5000000000000000000000000000000000000000000000000"
        "000000000000000000000000000000000000000000001", 0x43384396bdf077cfULL },
    { FT_D, "1.1609254979344313684971019152205940910254436661683478311545870964"
        "5828605516726383939385414123535156251E-20", 0x3bcb695d321625a5ULL },
    { FT_D, "156492447544237849681431182836481782826638770176.000000000000000000000010",
        0x49bb695d321625a5ULL },
    /* 0xffffe in first check */
    { FT_D, "9.2896795050136178599959262527972856521296662890563311520963907241821289062501E-10",
        0x3e0feb49db9c9de9ULL },
    { FT_D, "9.2896795050137460729908719720868907204769371332986338529735803604"
        "1259765625000001E-10", 0x3e0feb49db9c9e65ULL },
    { FT_D, "4.5395098885248518922272288095193501529226470624229992247242416071"
        "348586682483644341520195343575583279971397132612764835357666015625E-34",
        0x3902db3c22b8298cULL },
    { FT_D, "4.5395098885248518922272288095193501529226470624229992247242416071"
        "34858668248364434152019534357558327997139713261276483535766601562501E-34",
        0x3902db3c22b8298dULL },
    { FT_D, "4.5395098885248518922272288095193501529226470624229992247242416071"
        "348586682483644341520195343575583279971397132612764835357666015625001E-34",
        0x3902db3c22b8298dULL },
    { FT_D, "4.5395098885248518922272288095193501529226470624229992247242416071"
        "3485866824836443415201953435755832799713971326127648353576660156250001E-34",
        0x3902db3c22b8298dULL },
    { FT_D, "4.5395098885248518922272288095193501529226470624229992247242416071"
        "348586682483644341520195343575583279971397132612764835357666015626E-34",
        0x3902db3c22b8298dULL },
    { FT_D, "0.24453547592710685176786711281238240189850330352783203125",
        0x3fcf4cf03fe8cbcaULL },
    /*
     * smallest denormals (half)
     */
    { FT_H, "2.98023223876953125E-8", 0x0000 },
    { FT_H, "2.98023223876953125000001E-8", 0x0001 },
    { FT_H, "2.980232238769531251E-8", 0x0001 },
    { FT_H, "2.98023223876953126E-8", 0x0001 },
    { FT_H, "2.980232238769631250000000E-8", 0x0001 },
    { FT_H, "3.91372498489e-8", 0x0001 },
    { FT_H, "2.98023223876953124E-8", 0x0000 },
    { FT_H, "2.9802322387695312499E-8", 0x0000 },
    { FT_H, "2.9802322387695311E-8", 0x0000 },
    { FT_H, "2.9802e-8", 0x0000 },
    { FT_H, "1.490116119384765625E-8", 0x0000 },
    { FT_H, "1.490116119384765626E-8", 0x0000 },
    { FT_H, "1.490116149384765626E-8", 0x0000 },
    { FT_H, "1.790116119384765626E-8", 0x0000 },
    { FT_H, "1.490116119384765624E-8", 0x0000 },
    { FT_H, "7.450580596923828125E-9", 0x0000 },
    { FT_H, "5.9604644775390625E-8", 0x0001 },
    { FT_H, "5.9604644775390624E-8", 0x0001 },
    { FT_H, "5.4604644775390624E-8", 0x0001 },
    { FT_H, "4.6804644775390624E-8", 0x0001 },
    { FT_H, "8.94069671630859375E-8", 0x0002 },
    { FT_H, "8.94069671630859374E-8", 0x0001 },
    { FT_H, "8.94069671630859374999E-8", 0x0001 },
    { FT_H, "8.94069671630859374999999999E-8", 0x0001 },
    { FT_H, "8.94069671630859365E-8", 0x0001 },
    { FT_H, "8.94069671630859274E-8", 0x0001 },
    { FT_H, "8.94069671630759374E-8", 0x0001 },
    { FT_H, "1.490116119384765625E-7", 0x0002 },
    { FT_H, "1.4901161193847656250001E-7", 0x0003 },
    { FT_H, "1.49011611938476562501E-7", 0x0003 },
    { FT_H, "1.4901161193847656251E-7", 0x0003 },
    { FT_H, "1.490116119384765626E-7", 0x0003 },
    { FT_H, "1.49011611938476563E-7", 0x0003 },
    { FT_H, "1.490116119584765626E-7", 0x0003 },
    { FT_H, "1.490116119384765624E-7", 0x0002 },
    { FT_H, "1.490116119384765615E-7", 0x0002 },
    { FT_H, "1.490116119384765525E-7", 0x0002 },
    /*
     * smallest denormals (float)
     */
    { FT_F, "7.0064923216240853546186479164495806564013097093825788587853414194"
        "4895541342930300743319094181060791015625E-46", 0x00000000ULL },
    { FT_F, "7.0064923216240853546186479164495806564013097093825788587853414194"
        "48955413429303007433190941810607910156251E-46", 0x00000001ULL },
    { FT_F, "7.0064923216240853546186479164495806564013097093825788587853414194"
        "4895541342930300743319094181060791015625001E-46", 0x00000001ULL },
    { FT_F, "7.0064923216240853546186479164495806564013097093825788587853414194"
        "4895541342930300743319094181060791015626E-46", 0x00000001ULL },
    { FT_F, "7.0064923216240853546186479164495806564013097093825788587853414194"
        "4895541342930300743319094181060791025625E-46", 0x00000001ULL },
    { FT_F, "7.0064923216240853546186479164495806564013097093825788587853414194"
        "4895541342930310743319094181060791015625E-46", 0x00000001ULL },
    { FT_F, "7.0064923216240853546186479164495806564013097093825888587853414194"
        "4895541342930300743319094181060791015625001E-46", 0x00000001ULL },
    { FT_F, "7.006492321624085354618647916449580656E-46", 0x00000000ULL },
    { FT_F, "7.016492321624085354618647916449580656E-46", 0x00000001ULL },
    { FT_F, "7.006492322624085354618647916449580656E-46", 0x00000001ULL },
    { FT_F, "7.006492321624085354618647926449580656E-46", 0x00000001ULL },
    { FT_F, "6.006788321624085354618647916449580656E-46", 0x00000000ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926707097"
        "24477706714651503716595470905303955078125E-46", 0x00000000ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926707097"
        "24477706714651503716595470905303955078127E-46", 0x00000000ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926707097"
        "24477706714651503716595470915303955078125E-46", 0x00000000ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546992894293926707097"
        "24477706714651503716595470905303955078125E-46", 0x00000000ULL },
    { FT_F, "3.50324775E-46", 0x00000000ULL },
    { FT_F, "3.90324775E-46", 0x00000000ULL },
    { FT_F, "4.30324775E-46", 0x00000000ULL },
    { FT_F, "2.1019476964872256063855943749348741969203929128147736576356024258"
        "34686624028790902229957282543182373046875E-45", 0x00000002ULL },
    { FT_F, "2.1019476964872256063855943749348741969203929128147736576356024258"
        "34686624028790902229957282543182373046875001E-45", 0x00000002ULL },
    { FT_F, "2.1019476964872256063855943749348741969203929128147736576356024258"
        "3468662402879090222995728254318237304687501E-45", 0x00000002ULL },
    { FT_F, "2.1019476964872256063855943749348741969203929128147736576356024258"
        "346866240287909022299572825431823730468751E-45", 0x00000002ULL },
    { FT_F, "2.1019476964872256063855943749348741969203929128147736576356024258"
        "34686624028790902229957282543182373046876E-45", 0x00000002ULL },
    { FT_F, "2.1019476964872256063855943749348741969203929128147736576356024258"
        "34686624028790912229957282543182373046875E-45", 0x00000002ULL },
    { FT_F, "2.1019476964872256063855943749348741969203929128147736576356024558"
        "34686624028790902229957282543182373046875001E-45", 0x00000002ULL },
    { FT_F, "2.1019476964872256063855943749348741969203929128147736576356024258"
        "34686624028790902229957282543182373046874E-45", 0x00000001ULL },
    { FT_F, "2.1019476964872256063855943749348741969203929128147736576356024258"
        "34686624028790902229957282543082373046874E-45", 0x00000001ULL },
    { FT_F, "2.1019476964872256063855943749348741969203929128147736576356024258"
        "34686624028790902229957282543182373046874E-45", 0x00000001ULL },
    { FT_F, "2.1019476964872256063855943749348741969203929128147736576356024258"
        "34686624018790902229957282543182373046874E-45", 0x00000001ULL },
    { FT_F, "2.1019476964872256063855943749348741969203929128147736576356024158"
        "34686624028790902229957282543182373046874E-45", 0x00000001ULL },
    { FT_F, "2.1019476964872256063855943749348741969103929128147736576356024258"
        "34686624028790902229957282543182373046874E-45", 0x00000001ULL },
    { FT_F, "2.1019476964872256E-45", 0x00000001ULL },
    { FT_F, "2.1019476864872256E-45", 0x00000001ULL },
    { FT_F, "2.1019475964872256063855943749348741969103929128147736576356024558"
        "34686624028790902229957282543182373046874E-45", 0x00000001ULL },
    { FT_F, "2.10194769648722560638559E-45", 0x00000001ULL },
    { FT_F, "2.1019476964872256063856E-45", 0x00000002ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926707097"
        "24477706714651503716595470905303955078125E-45", 0x00000002ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926707097"
        "2447770671465150371659547090530395507812501E-45", 0x00000003ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926707097"
        "244777067146515037165954709053039550781250000001E-45", 0x00000003ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926707097"
        "244777067146515037165954709053039550781251E-45", 0x00000003ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926707097"
        "24477706714651503716595470905303955078126E-45", 0x00000003ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926707097"
        "24477706714651503716595473905303955078125E-45", 0x00000003ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926707097"
        "2447771671465150371659547090530395507812501E-45", 0x00000003ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926807097"
        "2447770671465150371659547090530395507812501E-45", 0x00000003ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546922894293926707097"
        "2447770671465150371659547090530395507812501E-45", 0x00000003ULL },
    { FT_F, "3.5032461608120426774093239582247903282006548546912894293926707097"
        "2447770671465150371659547090530395507812501E-45", 0x00000003ULL },
    { FT_F, "3.5032461608120426773094239582247903282006548546912894293926707097"
        "2447770671465150371659547090530395507812501E-45", 0x00000003ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926707097"
        "24477706714651503716595470905303955078124E-45", 0x00000002ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894293926707097"
        "24477606714651503716595470905303955078125E-45", 0x00000002ULL },
    { FT_F, "3.5032461608120426773093239582247903282006548546912894292926707097"
        "24477706714651503716595470905303955078125E-45", 0x00000002ULL },
    { FT_F, "3.5032461608120426773093239582247903281006548546912894293926707097"
        "24477706714651503716595470905303955078125E-45", 0x00000002ULL },
    { FT_F, "3.5032461608120426772093239582247903282006548546912894293926707097"
        "24477706714651503716595470905303955078125E-45", 0x00000002ULL },
    { FT_F, "3.5032461508120426773093239582247903282006548546912894293926707097"
        "24477706714651503716595470905303955078125E-45", 0x00000002ULL },
    /*
     * smallest denormals (double)
     */
    { FT_D, "2.4703282292062327208828439643411068618252990130716238221279284125"
        "0337753635104375932649918180817996189898282347722858865463328355177969"
        "8981993873980053909390631503565951557022639229085839244910518443593180"
        "2849936536152500319370457678249219365623669863658480757001585769269903"
        "7063119282795585513329278343384093519780155312465972635795746227664652"
        "7282722005637400648549997709659947045402082816622623785739345073633900"
        "7967761930577506740176324673600968951340535537458516661134223766678604"
        "1621596804619144672918403005300575308490487653917113865916462395249126"
        "2365388187963623937328042389101867234849766823508986338858792562830275"
        "5995657524455507255189313690836254779186948667994968324049705821028513"
        "185451396213837722826145437693412532098591327667236328125E-324",
        0x0000000000000000ULL },
    { FT_D, "2.4703282292062327208828439643411068618252990130716238221279284125"
        "0337753635104375932649918180817996189898282347722858865463328355177969"
        "8981993873980053909390631503565951557022639229085839244910518443593180"
        "2849936536152500319370457678249219365623669863658480757001585769269903"
        "7063119282795585513329278343384093519780155312465972635795746227664652"
        "7282722005637400648549997709659947045402082816622623785739345073633900"
        "7967761930577506740176324673600968951340535537458516661134223766678604"
        "1621596804619144672918403005300575308490487653917113865916462395249126"
        "2365388187963623937328042389101867234849766823508986338858792562830275"
        "5995657524455507255189313690836254779186948667994968324049705821028513"
        "1854513962138377228261454376934125320985913276672363281250001E-324",
        0x0000000000000001ULL },
    { FT_D, "2.4703282292062327208828439643411068618252990130716238221279284125"
        "0337753635104375932649918180817996189898282347722858865463328355177969"
        "8981993873980053909390631503565951557022639229085839244910518443593180"
        "2849936536152500319370457678249219365623669863658480757001585769269903"
        "7063119282795585513329278343384093519780155312465972635795746227664652"
        "7282722005637400648549997709659947045402082816622623785739345073633900"
        "7967761930577506740176324673600968951340535537458516661134223766678604"
        "1621596804619144672918403005300575308490487653917113865916462395249126"
        "2365388187963623937328042389101867234849766823508986338858792562830275"
        "5995657524455507255189313690836254779186948667994968324049705821028513"
        "1854513962138377228261454376934125320985913276672363281251E-324",
        0x0000000000000001ULL },
    { FT_D, "2.4703282292062327208828439643411068618252990130716238221279284125"
        "0337753635104375932649918180817996189898282347722858865463328355177969"
        "8981993873980053909390631503565951557022639229085839244910518443593180"
        "2849936536152500319370457678249219365623669863658480757001585769269903"
        "7063119282795585513329278343384093519780155312465972635795746227664652"
        "7282722005637400648549997709659947045402082816622623785739345073633900"
        "7967761930577506740176324673600968951340535537458516661134223766678604"
        "1621596804619144672918403005300575308490487653917113865916462395249126"
        "2365388187963623937328042389101867234849766823508986338858792562830275"
        "5995657524455507255189313690836254779186948667994968324049705821028513"
        "185451396213837722826145437693412532098591327667236328126E-324",
        0x0000000000000001ULL },
    { FT_D, "2.4703282292062327208828439643411068618252990130716238221279284125"
        "0337753635104375932649918180817996189898282347722858865463328355177969"
        "8981993873980053909390631503565951557022639229085839244910518443593180"
        "2849936536152500319370457678249219365623669863658480757001585769269903"
        "7063119282795585513329278343384093519780155312465972635795746227664652"
        "7282722005637400648549997709659947045402082816622623785739345073633900"
        "7967761930577506740176324673600968951340535537458516661134223766678604"
        "1621596804619144672918403005300575308490487653917113865916462395249126"
        "2365388187963623937328042389101867234849766823508986338858792562830275"
        "5995657524455507255189313690836254779186948667994968324049705821028513"
        "185451396213837722826145437693412533098591327667236328125E-324",
        0x0000000000000001ULL },
    { FT_D, "2.4703282292062327208828439643411068618252990130716238221279284125"
        "0337753635104375932649918180817996189898282347722858865463328355177969"
        "8981993873980053909390631503565951557022639229085839244910518443593180"
        "2849936536152500319370457678249219365623669863658480757001585769269903"
        "7063119282795585513329278343384093519780155312465972635795746227664652"
        "7282722005637400648549997709659947045402082816622623785739345073633900"
        "7967761930577506740176324673600968951340535537458516661134223766678604"
        "1621596804619144672918403005300575308490487653917113865916462395249126"
        "2365388187963623937328042389101867234849766823508986338858792562830275"
        "5995657524455507255189313690836254779186948667994968324049705821028513"
        "185451396213837722826145437693412532098591327667236328124999E-324",
        0x0000000000000000ULL },
    { FT_D, "2.4703282292062327208828439643411068618252990130716238221279284125"
        "0337753635104375932649918180817996189898282347722858865463328355177969"
        "8981993873980053909390631503565951557022639229085839244910518443593180"
        "2849936536152500319370457678249219365623669863658480757001585769269903"
        "7063119282795585513329278343384093519780155312465972635795746227664652"
        "7282722005637400648549997709659947045402082816622623785739345073633900"
        "7967761930577506740176324673600968951340535537458516661134223766678604"
        "1621596804619144672918403005300575308490487653917113865916462395249126"
        "2365388187963623937328042389101867234849766823508986338858792562830275"
        "5995657524455507255189313690836254779186948667994968324049705821028513"
        "185451396213837722826135437693412532098591327667236328125E-324",
        0x0000000000000000ULL },
    { FT_D, "2.47032822920623272088284396434110686182529E-324", 0x0000000000000000ULL },
    { FT_D, "2.4703282292062327208828439643411068618252992E-324", 0x0000000000000001ULL },
    { FT_D, "1.2351641146031163604414219821705534309126495065358119110639642062"
        "5168876817552187966324959090408998094949141173861429432731664177588984"
        "9490996936990026954695315751782975778511319614542919622455259221796590"
        "1424968268076250159685228839124609682811834931829240378500792884634951"
        "8531559641397792756664639171692046759890077656232986317897873113832326"
        "3641361002818700324274998854829973522701041408311311892869672536816950"
        "3983880965288753370088162336800484475670267768729258330567111883339302"
        "0810798402309572336459201502650287654245243826958556932958231197624563"
        "1182694093981811968664021194550933617424883411754493169429396281415137"
        "7997828762227753627594656845418127389593474333997484162024852910514256"
        "5927256981069188614130727188467062660492956638336181640625E-324",
        0x0000000000000000ULL },
    { FT_D, "4.9406564584124654417656879286822137236505980261432476442558568250067550"
        "7270208751865299836361635992379796564695445717730926656710355939796398"
        "7747960107818781263007131903114045278458171678489821036887186360569987"
        "3072305000638740915356498438731247339727316961514003171538539807412623"
        "8565591171026658556686768187039560310624931945271591492455329305456544"
        "4011274801297099995419319894090804165633245247571478690147267801593552"
        "3861155013480352649347201937902681071074917033322268447533357208324319"
        "3609238289345836806010601150616980975307834227731832924790498252473077"
        "6375927247874656084778203734469699533647017972677717585125660551199131"
        "5048911014510378627381672509558373897335989936648099411642057026370902"
        "79242767544565229087538682506419718265533447265625E-324",
        0x0000000000000001ULL },
    { FT_D, "4.9406564584124654417656879286822137236505980261432476442558568250067550"
        "7270208751865299836361635992379796564695445717730926656710355939796398"
        "7747960107818781263007131903114045278458171678489821036887186360569987"
        "3072305000638740915356498438731247339727316961514003171538539807412623"
        "8565591171026658556686768187039560310624931945271591492455329305456544"
        "4011274801297099995419319894090804165633245247571478690147267801593552"
        "3861155013480352649347201937902681071074917033322268447533357208324319"
        "3609238289345836806010601150616980975307834227731832924790498252473077"
        "6375927247874656084778203734469699533647017972677717585125660551199131"
        "5048911014510378627381672509558373897335989936648099411642057026370902"
        "79242767544565229087538682506419718265533447265624E-324",
        0x0000000000000001ULL },
    { FT_D, "4.9406564584124654417656879286822137236505980261432476442558568250067550"
        "7270208751865299836361635992379796564695445717730926656710355939796398"
        "7747960107818781263007131903114045278458171678489821036887186360569987"
        "3072305000638740915356498438731247339727316961514003171538539807412623"
        "8565591171026658556686768187039560310624931945271591492455329305456544"
        "4011274801297099995419319894090804165633245247571478690147267801593552"
        "3861155013480352649347201937902681071074917033322268447533357208324319"
        "3609238289345836806010601150616980975307834227731832924790498252473077"
        "6375927247874656084778203734469699533647017972677717585125660551199131"
        "5048911014510378627381672509558373897335989936648099411642057026370902"
        "79242767544565229087538682506419718265533447265626E-324",
        0x0000000000000001ULL },
    { FT_D, "4.9406564584124654417656879286822137236505980261432476442558568250067550"
        "7270208751865299836361635992379796564695445717730926656710355939796398"
        "7747960107818781263007131903114045278458171678489821036887186360569987"
        "3072305000638740915356498438731247339727316961514003171538539807412623"
        "8565591171026658556686768187039560310624931945271591492455329305456544"
        "4011274801297099995419319894090804165633245247571478690147267801593552"
        "3861155013480352649347201937902681071074917033322268447533357208324319"
        "3609238289345836806010601150616980975307834227731832924790498252473077"
        "6375927247874656084778203734469699533647017972677717585125660551199131"
        "5048911014510378627381772509558373897335989936648099411642057026370902"
        "79242767544565229087538682506419718265533447265625E-324",
        0x0000000000000001ULL },
    { FT_D, "7.4109846876186981626485318930233205854758970392148714663837852375"
        "1013260905313127797949754542453988569694847043168576596389985065533909"
        "6945981621940161728171894510697854671067917687257517734731555330779540"
        "8549809608457500958111373034747658096871009590975442271004757307809711"
        "1189357848386756539987835030152280559340465937397917907387238682993958"
        "1848166016912201945649993128979841136206248449867871357218035220901702"
        "3903285791732520220528974020802906854021606612375549983402671300035812"
        "4864790413857434018755209015901725925471462961751341597749387185747378"
        "7096164563890871811984127167305601704549300470526959016576377688490826"
        "7986972573366521765567941072508764337560846003984904972149117463085539"
        "556354188641513168478436313080237596295773983001708984375E-324",
        0x0000000000000002ULL },
    { FT_D, "7.4109846876186981626485318930233205854758970392148714663837852375"
        "1013260905313127797949754542453988569694847043168576596389985065533909"
        "6945981621940161728171894510697854671067917687257517734731555330779540"
        "8549809608457500958111373034747658096871009590975442271004757307809711"
        "1189357848386756539987835030152280559340465937397917907387238682993958"
        "1848166016912201945649993128979841136206248449867871357218035220901702"
        "3903285791732520220528974020802906854021606612375549983402671300035812"
        "4864790413857434018755209015901725925471462961751341597749387185747378"
        "7096164563890871811984127167305601704549300470526959016576377688490826"
        "7986972573366521765567941072508764337560846003984904972149117463085539"
        "556354188641513168478436313080237596295773983001708984374999E-324",
        0x0000000000000001ULL },
    { FT_D, "7.4109846876186981626485318930233205854758970392148714663837852375"
        "1013260905313127797949754542453988569694847043168576596389985065533909"
        "6945981621940161728171894510697854671067917687257517734731555330779540"
        "8549809608457500958111373034747658096871009590975442271004757307809711"
        "1189357848386756539987835030152280559340465937397917907387238682993958"
        "1848166016912201945649993128979841136206248449867871357218035220901702"
        "3903285791732520220528974020802906854021606612375549983402671300035812"
        "4864790413857434018755209015901725925471462961751341597749387185747378"
        "7096164563890871811984127167305601704549300470526959016576377688490826"
        "7986972573366521765567941072508764337560846003984904972149117463085539"
        "556354188641513168478436313080237596295773983001708984374E-324",
        0x0000000000000001ULL },
    { FT_D, "7.4109846876186981626485318930233205854758970392148714663837852375"
        "1013260905313127797949754542453988569694847043168576596389985065533909"
        "6945981621940161728171894510697854671067917687257517734731555330779540"
        "8549809608457500958111373034747658096871009590975442271004757307809711"
        "1189357848386756539987835030152280559340465937397917907387238682993958"
        "1848166016912201945649993128979841136206248449867871357218035220901702"
        "3903285791732520220528974020802906854021606612375549983402671300035812"
        "4864790413857434018755209015901725925471462961751341597749387185747378"
        "7096164563890871811984127167305601704549300470526959016576377688490826"
        "7986972573366521765567941072508764337560846003984904972149117463085539"
        "556354188641513168478436313080237595295773983001708984375E-324",
        0x0000000000000001ULL },
    { FT_D, "7.4109846876186981626485318930233205854758970392148714663837852375"
        "1013260905313127797949754542453988569694847043168576596389985065533909"
        "6945981621940161728171894510697854671067917687257517734731555330779540"
        "8549809608457500958111373034747658096871009590975442271004757307809711"
        "1189357848386756539987835030152280559340465937397917907387238682993958"
        "1848166016912201945649993128979841136206248449867871357218035220901702"
        "3903285791732520220528974010802906854021606612375549983402671300035812"
        "4864790413857434018755209015901725925471462961751341597749387185747378"
        "7096164563890871811984127167305601704549300470526959016576377688490826"
        "7986972573366521765567941072508764337560846003984904972149117463085539"
        "556354188641513168478436313080237596295773983001708984375E-324",
        0x0000000000000001ULL },
    { FT_D, "1.2351641146031163604414219821705534309126495065358119110639642062"
        "5168876817552187966324959090408998094949141173861429432731664177588984"
        "9490996936990026954695315751782975778511319614542919622455259221796590"
        "1424968268076250159685228839124609682811834931829240378500792884634951"
        "8531559641397792756664639171692046759890077656232986317897873113832326"
        "3641361002818700324274998854829973522701041408311311892869672536816950"
        "3983880965288753370088162336800484475670267768729258330567111883339302"
        "0810798402309572336459201502650287654245243826958556932958231197624563"
        "1182694093981811968664021194550933617424883411754493169429396281415137"
        "7997828762227753627594656845418127389593474333997484162024852910514256"
        "5927256981069188614130727188467062660492956638336181640625E-323",
        0x0000000000000002ULL },
    { FT_D, "1.2351641146031163604414219821705534309126495065358119110639642062"
        "5168876817552187966324959090408998094949141173861429432731664177588984"
        "9490996936990026954695315751782975778511319614542919622455259221796590"
        "1424968268076250159685228839124609682811834931829240378500792884634951"
        "8531559641397792756664639171692046759890077656232986317897873113832326"
        "3641361002818700324274998854829973522701041408311311892869672536816950"
        "3983880965288753370088162336800484475670267768729258330567111883339302"
        "0810798402309572336459201502650287654245243826958556932958231197624563"
        "1182694093981811968664021194550933617424883411754493169429396281415137"
        "7997828762227753627594656845418127389593474333997484162024852910514256"
        "592725698106918861413072718846706266049295663833618164062500001E-323",
        0x0000000000000003ULL },
    { FT_D, "1.2351641146031163604414219821705534309126495065358119110639642062"
        "5168876817552187966324959090408998094949141173861429432731664177588984"
        "9490996936990026954695315751782975778511319614542919622455259221796590"
        "1424968268076250159685228839124609682811834931829240378500792884634951"
        "8531559641397792756664639171692046759890077656232986317897873113832326"
        "3641361002818700324274998854829973522701041408311311892869672536816950"
        "3983880965288753370088162336800484475670267768729258330567111883339302"
        "0810798402309572336459201502650287654245243826958556932958231197624563"
        "1182694093981811968664021194550933617424883411754493169429396281415137"
        "7997828762227753627594656845418127389593474333997484162024852910514256"
        "5927256981069188614130727188467062660492956638336181640626E-323",
        0x0000000000000003ULL },
    { FT_D, "1.2351641146031163604414219821705534309126495065358119110639642062"
        "5168876817552187966324959090408998094949141173861429432731664177588984"
        "9490996936990026954695315751782975778511319614542919622455259221796590"
        "1424968268076250159685228839124609682811834931829240378500792884634951"
        "8531559641397792756664639171692046759890077656232986317897873113832326"
        "3641361002818700324274998854829973522701041408311311892869672536816950"
        "3983880965288753370088162336800484475670267768729258330567111883339302"
        "0810798402309572336459201502650287654245243826958556932958231197624563"
        "1182694093981811968664021194550933617424883411754493169429396281415137"
        "7997828762227753627594656845418127389593474333997484162024852910514256"
        "5927256981069188614130727288467062660492956638336181640625E-323",
        0x0000000000000003ULL },
    { FT_D, "1.2351641146031163604414219821705534309126495065358119110639642062"
        "5168876817552187966324959090408998094949141173861429432731664177588984"
        "9490996936990026954695315751782975778511319614542919622455259221796590"
        "1424968268076250159685228839124609682811834931829240378500792884634951"
        "8531559641397792756664639171692046759890077656232986317897873113832326"
        "3641361002818700324274998854829973522701041408311311892869672536816950"
        "3983880965288753370088162336800484475670267768729258330567111883339302"
        "0810798402309572336459201502650287654245243826958556932958231197624563"
        "1182694093981811968664021194550933617424883411754493169429396281415137"
        "7997828762227753627594656845418127389593474333997484162024852910514256"
        "592725698106918861413072718846706266049295663833618164062499E-323",
        0x0000000000000002ULL },
    { FT_D, "1.2351641146031163604414219821705534309126495065358119110639642062"
        "5168876817552187966324959090408998094949141173861429432731664177588984"
        "9490996936990026954695315751782975778511319614542919622455259221796590"
        "1424968268076250159685228839124609682811834931829240378500792884634951"
        "8531559641397792756664639171692046759890077656232986317897873113832326"
        "3641361002818700324274998854829973522701041408311311892869672536816950"
        "3983880965288753370088162336800484475670267768729258330567111883339302"
        "0810798402309572336459201502650287654245243826958556932958231197624563"
        "1182694093981811968664021194550933617424883411754493169429396281415137"
        "7997828762227753627594656845418127389593474333997484162024852910514256"
        "5927256981069188614130727188467062660492956638336181630626E-323",
        0x0000000000000002ULL },
        /*
         * roundings (half)
         */
        { FT_H, "6.86132812500", 0x46dc },
        { FT_H, "6.861328125", 0x46dc },
        { FT_H, "6.86132812501", 0x46dd },
        { FT_H, "6.8613281251", 0x46dd },
        { FT_H, "6.861328125000000003", 0x46dd },
        { FT_H, "6.861328125000000000000000000000004", 0x46dd },
        { FT_H, "6.861328126", 0x46dd },
        { FT_H, "6.8613283", 0x46dd },
        { FT_H, "6.8613281249999", 0x46dc },
        { FT_H, "6.8613281247889", 0x46dc },
        { FT_H, "6.86132811", 0x46dc },
        { FT_H, "6.861328049999", 0x46dc },
        { FT_H, "6.86523437500", 0x46de },
        { FT_H, "6.86523437501", 0x46de },
        { FT_H, "6.8652343751", 0x46de },
        { FT_H, "6.86523437500000001", 0x46de },
        { FT_H, "6.865234375000000000000000001", 0x46de },
        { FT_H, "6.865234376", 0x46de },
        { FT_H, "6.8652344", 0x46de },
        { FT_H, "6.8652343750003", 0x46de },
        { FT_H, "6.86523437499", 0x46dd },
        { FT_H, "6.86523437", 0x46dd },
        { FT_H, "0.0406646728515625", 0x2934 },
        { FT_H, "0.040664672851562501", 0x2935 },
        { FT_H, "0.040664672851562499", 0x2934 },
        { FT_H, "0.0406951904296875", 0x2936 },
        { FT_H, "0.0406951904296874999", 0x2935 },
        { FT_H, "0.040695190429686", 0x2935 },
        { FT_H, "0.0406951904296875001", 0x2936 },
        /* with promotion (half) */
        { FT_H, "63.98437500000", 0x5400 },
        { FT_H, "63.984374999999999999999", 0x53ff },
        { FT_H, "63.98437501000", 0x5400 },
        { FT_H, "63.984475", 0x5400 },
        { FT_H, "63.985375", 0x5400 },
        { FT_H, "63.984374", 0x53ff },
        { FT_H, "63.984364", 0x53ff },
        { FT_H, "63.984274", 0x53ff },
        { FT_H, "0.03124237060546875", 0x2800 },
        { FT_H, "0.03124237060546876", 0x2800 },
        { FT_H, "0.03124237060546875002", 0x2800 },
        { FT_H, "0.03124237060546874", 0x27ff },
        { FT_H, "0.03124237060546874999999999", 0x27ff },
        { FT_H, "0.0312423706", 0x27ff },
        { FT_H, "0.0312423", 0x27ff },
        /* with promotion from denormal to normalized (half) */
        { FT_H, "0.0000610053539276123046875", 0x0400 },
        { FT_H, "0.000061005353927612304687499", 0x03ff },
        { FT_H, "0.000061005353927612304687499999999", 0x03ff },
        { FT_H, "0.000061005353927612304687500001", 0x0400 },
        { FT_H, "0.00006100535392761230", 0x03ff },
        { FT_H, "0.00006100535392", 0x03ff },
        /* rounding for denormals (half) */
        { FT_H, "0.0000226199626922607421875001", 0x017c },
        { FT_H, "0.0000226199626922607421875", 0x017c },
        { FT_H, "0.00002261996269226074218749999999", 0x017b },
        { FT_H, "0.0000226199626922607421874", 0x017b },
        { FT_H, "0.0000226199626922", 0x017b },
        { FT_H, "0.00002261996", 0x017b },
        { FT_H, "0.0000226199626922607421876", 0x017c },
        { FT_H, "0.000022619962692261", 0x017c },
        { FT_H, "0.000022619962693", 0x017c },
        { FT_H, "0.0000227987766265869140625", 0x017e },
        { FT_H, "0.000022798776626586914062499999", 0x017e },
        { FT_H, "0.0000227987766265869140625000000000000001", 0x017f },
        { FT_H, "0.0000227987766265869140625000000001", 0x017f },
        { FT_H, "0.0000227987766265869140626", 0x017f },
        { FT_H, "0.0000227987766265869141626", 0x017f },
        { FT_H, "0.000022798776626587", 0x017f },
        { FT_H, "0.0000227987766265869140624", 0x017e },
        { FT_H, "0.0000227987766264", 0x017e },
        { FT_H, "0.000022798776", 0x017e },
        { FT_H, "0.0000015795230865478515625", 0x001a },
        { FT_H, "0.00000157952308654785156250001", 0x001b },
        { FT_H, "0.0000015795230865478515624999", 0x001a },
        { FT_H, "0.000001579523086547851", 0x001a },
        { FT_H, "0.00000157952308654", 0x001a },
        { FT_H, "0.00000157952308654785156250000000002", 0x001b },
        { FT_H, "0.0000012814998626708984375", 0x0016 },
        { FT_H, "0.0000012814998626708984375000001", 0x0016 },
        { FT_H, "0.000001281499862670898437499999", 0x0015 },
        { FT_H, "0.0000012814998626708984", 0x0015 },
        { FT_H, "0.000001281499862670897", 0x0015 },
        /*
         * roundings (float)
         */
        { FT_F, "6520.340576171875000000000000", 0x45cbc2ba },
        { FT_F, "6520.340576171875000000000001", 0x45cbc2ba },
        { FT_F, "6520.340576171875001", 0x45cbc2ba },
        { FT_F, "6520.3405761718751", 0x45cbc2ba },
        { FT_F, "6520.340576171876", 0x45cbc2ba },
        { FT_F, "6520.340576371875", 0x45cbc2ba },
        { FT_F, "6520.340576172", 0x45cbc2ba },
        { FT_F, "6520.341", 0x45cbc2ba },
        { FT_F, "6520.3405761718749999999999999", 0x45cbc2b9 },
        { FT_F, "6520.34057617187499", 0x45cbc2b9 },
        { FT_F, "6520.340576171874", 0x45cbc2b9 },
        { FT_F, "6520.340576071875", 0x45cbc2b9 },
        { FT_F, "6520.3405761718", 0x45cbc2b9 },
        { FT_F, "6520.3405", 0x45cbc2b9 },
        { FT_F, "6520.337158203125000000000000", 0x45cbc2b2 },
        { FT_F, "6520.337158203125000000000001", 0x45cbc2b3 },
        { FT_F, "6520.337158203125001", 0x45cbc2b3 },
        { FT_F, "6520.3371582031251", 0x45cbc2b3 },
        { FT_F, "6520.337158203126", 0x45cbc2b3 },
        { FT_F, "6520.337158213125", 0x45cbc2b3 },
        { FT_F, "6520.337168213125", 0x45cbc2b3 },
        { FT_F, "6520.337158204", 0x45cbc2b3 },
        { FT_F, "6520.33716", 0x45cbc2b3 },
        { FT_F, "6520.3371582031249999999999999", 0x45cbc2b2 },
        { FT_F, "6520.33715820312499", 0x45cbc2b2 },
        { FT_F, "6520.3371582031249", 0x45cbc2b2 },
        { FT_F, "6520.337158203124", 0x45cbc2b2 },
        { FT_F, "6520.33715820", 0x45cbc2b2 },
        { FT_F, "6520.33715", 0x45cbc2b2 },
        { FT_F, "6520.337158103124", 0x45cbc2b2 },
        { FT_F, "8.73165419079668936319649219512939453125E-7", 0x356a6378 },
        { FT_F, "8.7316541907966893631964921951293945312500001E-7", 0x356a6379 },
        { FT_F, "8.7316541907966893631964921951293945312500000001E-7", 0x356a6379 },
        { FT_F, "8.731654190796689363196492195129394531251E-7", 0x356a6379 },
        { FT_F, "8.73165419079668936319649219512939453126E-7", 0x356a6379 },
        { FT_F, "8.73165419079668936319649219532939453125E-7", 0x356a6379 },
        { FT_F, "8.73165419079668936329649219532939453125E-7", 0x356a6379 },
        { FT_F, "8.73165419079678936329649219532939453125E-7", 0x356a6379 },
        { FT_F, "8.7316541907966893631964921952E-7", 0x356a6379 },
        { FT_F, "8.7316541907966893632E-7", 0x356a6379 },
        { FT_F, "8.73165419079668936319649219512939453E-7", 0x356a6378 },
        { FT_F, "8.73165419079668936319649209512939453E-7", 0x356a6378 },
        { FT_F, "8.73165419079668936219649209512939453E-7", 0x356a6378 },
        { FT_F, "8.73165419079668936319649219512E-7", 0x356a6378 },
        { FT_F, "8.7316541907966893631964E-7", 0x356a6378 },
        { FT_F, "8.73165419079E-7", 0x356a6378 },
        { FT_F, "8.73165589609925518743693828582763671875E-7", 0x356a637c },
        { FT_F, "8.73165589609925518743693828582763671875001E-7", 0x356a637c },
        { FT_F, "8.731655896099255187436938285827636718750000001E-7", 0x356a637c },
        { FT_F, "8.73165589609925518743693828582763671876E-7", 0x356a637c },
        { FT_F, "8.731655896099255187436938285828E-7", 0x356a637c },
        { FT_F, "8.731655896099255187436939E-7", 0x356a637c },
        { FT_F, "8.7316558961E-7", 0x356a637c },
        { FT_F, "8.73165589609925518743693838582763671875E-7", 0x356a637c },
        { FT_F, "8.73165589609925528743693838582763671875E-7", 0x356a637c },
        { FT_F, "8.73165589629925518743693838582763671875E-7", 0x356a637c },
        { FT_F, "8.73165589609925518743693828582763671874999E-7", 0x356a637b },
        { FT_F, "8.731655896099255187436938285827636718E-7", 0x356a637b },
        { FT_F, "8.7316558960992551874369382858E-7", 0x356a637b },
        { FT_F, "8.7316558960992551874E-7", 0x356a637b },
        { FT_F, "8.731655896099255182436938285827636718E-7", 0x356a637b },
        /* with promotion (float) */
        { FT_F, "70368742080512", 0x56800000 },
        { FT_F, "70368742080511.9999999", 0x567fffff },
        { FT_F, "70368742080511.99999", 0x567fffff },
        { FT_F, "70368742080511", 0x567fffff },
        { FT_F, "70368742080500", 0x567fffff },
        { FT_F, "70368742080512.0001", 0x56800000 },
        { FT_F, "70368742080512.1", 0x56800000 },
        { FT_F, "70368742080513", 0x56800000 },
        { FT_F, "70368742080523", 0x56800000 },
        { FT_F, "4.6566127342995144999804324470460414886474609375E-10", 0x30000000 },
        { FT_F, "4.6566127342995144999804324470460414886474609375001E-10", 0x30000000 },
        { FT_F, "4.65661273429951449998043244704604148864746093751E-10", 0x30000000 },
        { FT_F, "4.6566127342995144999804324470460414886474609376E-10", 0x30000000 },
        { FT_F, "4.6566127342995144999804324470460414886474609374E-10", 0x2fffffff },
        { FT_F, "4.6566127342995144999804324470460414886474609374999E-10", 0x2fffffff },
        { FT_F, "4.65661273429951449998043244704604148864E-10", 0x2fffffff },
        /* with promotion from denormal to normalized (float) */
        { FT_F, "1.175494280757364291727882991035766513322858992758990427682963"
            "1184250030649651730385585324256680905818939208984375E-38", 0x00800000 },
        { FT_F, "1.175494280757364291727882991035766513322858992758990427682963"
            "1184250030649651730385585324256680905818939208984374E-38", 0x007fffff },
        { FT_F, "1.175494280757364291727882991035766513322858992758990427682963"
            "11842500306496517303855853242566809058189E-38", 0x007fffff },
        { FT_F, "1.175494280757364291727882991035766513322858992758990427682963"
            "1184250030649E-38", 0x007fffff },
        { FT_F, "1.175494280757364291727882991035766513322858992758990427682963"
            "1184250030649651730385585324256680905818939208984375001E-38", 0x00800000 },
        { FT_F, "1.175494280757364291727882991035766513322858992758990427682963"
            "1184250030649651730385585324256680905818939208984376E-38", 0x00800000 },
        { FT_F, "1.1754942807573642917278829910357665133228589928E-38", 0x00800000 },
        /* rounding for denormals (float) */
        { FT_F, "2.79061582677965695589106127864270347963807764414998733366561"
            "36339523244516147570948305656202137470245361328125E-41", 0x00004dca },
        { FT_F, "2.79061582677965695589106127864270347963807764414998733366561"
            "363395232445161475709483056562021374702453613281250001E-41", 0x00004dcb },
        { FT_F, "2.79061582677965695589106127864270347963807764414998733366561"
            "363395232445161475709483056562021374702453613281251E-41", 0x00004dcb },
        { FT_F, "2.79061582677965695589106127864270347963807764414998733366561"
            "36339523244516147570948305656202137470245361328126E-41", 0x00004dcb },
        { FT_F, "2.79061582677965695589106127864270347963807764414998733366561"
            "3633952324451614757094830565621E-41", 0x00004dcb },
        { FT_F, "2.79061582677965695589106127864270347963807764414998733366561"
            "3636E-41", 0x00004dcb },
        { FT_F, "2.7906158267797E-41", 0x00004dcb },
        { FT_F, "2.79061582677965695589106127864270347963807764414998733366561"
            "363395232445161475709483E-41", 0x00004dca },
        { FT_F, "2.79061582677965695589106E-41", 0x00004dca },
        { FT_F, "2.79061582677965695589106127864270347963807764414998733366561"
            "36339523244516147570948305656202137470245361328124999E-41", 0x00004dca },
            
        { FT_F, "2.79131647601181936442652314343434843770371777512092559155149"
            "21680942693471561000251313089393079280853271484375E-41", 0x00004dd0 },
        { FT_F, "2.79131647601181936442652314343434843770371777512092559155149"
            "216809426934715610002513130893930792808532714843750001E-41", 0x00004dd0 },
        { FT_F, "2.79131647601181936442652314343434843770371777512092559155149"
            "21680942693471561000251313089393079280853271484376E-41", 0x00004dd0 },
        { FT_F, "2.79131647601181936442652314343434843770371777512092559155149"
            "2168095E-41", 0x00004dd0 },
        { FT_F, "2.791316476011819364426523143434348437703717775120926E-41", 0x00004dd0 },
        { FT_F, "2.79131647601181936442652314343434843770371777512092559155149"
            "21680942693471561000251313089393079280853271484374999999E-41", 0x00004dcf },
        { FT_F, "2.79131647601181936442652314343434843770371777512092559155149"
            "2168094269347156100025131308939307928085327148437499E-41", 0x00004dcf },
        { FT_F, "2.79131647601181936442652314343434843770371777512092559155149"
            "2168094269347156100025131308939307E-41", 0x00004dcf },
        { FT_F, "2.79131647601181936442652314343434843770371E-41", 0x00004dcf },
        /*
         * roundings (double)
         */
        { FT_D, "274327438359255654923528830976", 0x460bb332b5409866ULL },
        { FT_D, "274327438359255654923528830976.00", 0x460bb332b5409866ULL },
        { FT_D, "274327438359255654923528830976.01", 0x460bb332b5409867ULL },
        { FT_D, "274327438359255654923528830976.0000001", 0x460bb332b5409867ULL },
        { FT_D, "274327438359255654923528830977", 0x460bb332b5409867ULL },
        { FT_D, "274327438359255654924000000000", 0x460bb332b5409867ULL },
        { FT_D, "274327438359255654923528830975.00", 0x460bb332b5409866ULL },
        { FT_D, "274327438359255654923528830975.49999", 0x460bb332b5409866ULL },
        { FT_D, "274327438359255654923520000000.000", 0x460bb332b5409866ULL },
        
        /*
         * examples of the incorrect conversions for other implementations
         */
        { FT_D, "9214843084008499", 0x43405e6cec57761aULL },
        { FT_D, "0.500000000000000166533453693773481063544750213623046875",
            0x3fe0000000000002ULL },
        { FT_D, "30078505129381147446200", 0x44997a3c7271b021ULL },
        { FT_D, "0.500000000000000166547006220929549868969843373633921146392822265625",
            0x3fe0000000000002ULL },
        { FT_D, "0.3932922657273", 0x3fd92bb352c4623aULL },
        { FT_D, "3.518437208883201171875e13", 0x42c0000000000002ULL },
        { FT_D, "62.5364939768271845828", 0x404f44abd5aa7ca4ULL },
        { FT_D, "8.10109172351e-10", 0x3e0bd5cbaef0fd0cULL },
        { FT_D, "1.50000000000000011102230246251565404236316680908203125",
            0x3ff8000000000000ULL },
        { FT_D, "9007199254740991.4999999999999999999999999999999995",
            0x433fffffffffffffULL },
        { FT_D, "5.0216813883093451685872615018317116712748411717802652598273e58",
            0x4c20000000000001ULL },
};

int main(int argc, const char** argv)
{
    int retVal = 0;
    for (cxuint i = 0; i < sizeof(cstrtofXTestCases)/sizeof(CStrtofXTestCase); i++)
        try
        { testCStrtofX(i, cstrtofXTestCases[i]); }
        catch(const std::exception& ex)
        {
            std::cerr << ex.what() << std::endl;
            retVal = 1;
        }
    for (cxuint i = 0; i < sizeof(cstrtofXTestCases)/sizeof(CStrtofXTestCase); i++)
        try
        { testTripping(i, cstrtofXTestCases[i]); }
        catch(const std::exception& ex)
        {
            std::cerr << ex.what() << std::endl;
            retVal = 1;
        }
    return retVal;
}
